package com.ruoyi.controller;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.PeopleAndPhotoInterfaceService;
import org.apache.commons.math3.analysis.function.Add;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 人员及照片接口控制器 Controller
 */
@RestController
@Anonymous
@RequestMapping("/Interface")
public class PeopleAndPhotoInterfaceController extends BaseController {

    @Resource
    PeopleAndPhotoInterfaceService peopleAndPhotoInterfaceService;

    /**
     * 添加人员v2
     */
    @PostMapping("/savePersonnel")
    public Object savePersonnel(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.savePersonnel(jsonObject);
    }

    /**
     * 修改人员
     */
    @PostMapping("/updatePersonnel")
    public Object updatePersonnel(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.updatePersonnel(jsonObject);
    }

    /**
     * 获取组织下人员列表v2
     */
    @PostMapping("/listOrganizationalStaff")
    public Object listOrganizationalStaff(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.listOrganizationalStaff(jsonObject);
    }

    /**
     * 获取人员列表v2
     */
    @PostMapping("/listStaff")
    public Object listStaff(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.listStaff(jsonObject);
    }

    /**
     * 查询人员列表v2
     */
    @PostMapping("/selectStaffList")
    public Object selectStaffList(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.selectStaffList(jsonObject);
    }

    /**
     * 批量删除人员
     */
    @PostMapping("/removeStaff")
    public Object removeStaff(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.removeStaff(jsonObject);
    }

    /**
     * 修改人脸
     */
    @PostMapping("/updateFace")
    public Object updateFace(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.updateFace(jsonObject);
    }

    /**
     * 添加人脸
     */
    @PostMapping("/saveFace")
    public Object saveFace(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.saveFace(jsonObject);
    }

    /**
     *  删除人脸 根据人脸Id删除人脸
     */
    @PostMapping("/removeFaceById")
    public Object removeFaceById(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.removeFaceById(jsonObject);
    }

    /**
     *  批量添加人员
     */
    @PostMapping("/saveListPersonnel")
    public Object saveListPersonnel(@RequestBody List<Add> addList) throws Exception {
        return peopleAndPhotoInterfaceService.saveListPersonnel(addList);
    }

    /**
     *  提取人员图片
     */
    @PostMapping("/downloadPersonnelImage")
    public Object downloadPersonnelImage(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.downloadPersonnelImage(jsonObject);
    }

    /**
     *  根据人员唯一字段获取人员详细信息
     */
    @PostMapping("/getPersonnelById")
    public Object getPersonnelById(@RequestBody JSONObject jsonObject) throws Exception {
        return peopleAndPhotoInterfaceService.getPersonnelById(jsonObject);
    }

}
